package com.sinosoft.cpyy.service.impl;

import com.sinosoft.cpyy.dao.master.TestPaperTestsMapper;
import com.sinosoft.cpyy.model.TestPaperTests;
import com.sinosoft.cpyy.model.TestPaperTestsList;
import com.sinosoft.cpyy.model.vo.TestPaperTestsVo;
import com.sinosoft.cpyy.service.TestPaperTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class TestPaperTestServiceImpl implements TestPaperTestService {

    private final TestPaperTestsMapper testPaperTestsMapper;

    @Autowired
    public TestPaperTestServiceImpl(TestPaperTestsMapper testPaperTestsMapper) {
        this.testPaperTestsMapper = testPaperTestsMapper;
    }

    @Override
    public List<TestPaperTestsVo> findSelectTestPaperQuesion(int testpaperId) {
        // TODO Auto-generated method stub
        return testPaperTestsMapper.findSelectTestPaperQuesion(testpaperId);
    }

    @Override
    public int deleteTestPaperTestById(int testpaperId) {
        // TODO Auto-generated method stub
        return testPaperTestsMapper.deleteTestPaperTestById(testpaperId);
    }

    @Override
    public int addTestPaperQuestion(TestPaperTestsList testPaperTestsList) {

        List<TestPaperTests> testPaperTests = new ArrayList<TestPaperTests>();

        for (Integer id : testPaperTestsList.getQuestionBankId()) {
            TestPaperTests temp = new TestPaperTests();
            temp.setQuestionBankId(id);
            temp.setTestpaperId(testPaperTestsList.getTestpaperId());
            testPaperTests.add(temp);
        }

        return testPaperTestsMapper.addTestPaperQuestion(testPaperTests);
    }

}
